package com.xlh.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 上传类型枚举
 * <p>
 * Created by lx on 2019/1/28.
 */
@Getter
@AllArgsConstructor
public enum UploadTypeEnum {

    FILE(1, "文件上传"),
    MARKDOWN(2, "markdown上传");

    private Integer code;

    private String message;

    public static UploadTypeEnum getByCode(Integer code) {
        for (UploadTypeEnum uploadTypeEnum : UploadTypeEnum.values()) {
            if (Objects.equals(uploadTypeEnum.getCode(), code)) {
                return uploadTypeEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        UploadTypeEnum templateTypeEnum = getByCode(code);
        return templateTypeEnum == null ? null : templateTypeEnum.getMessage();
    }

}
